﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PingGuLsit.aspx.cs" Inherits="PropertyAppraisal.ProjectAppraisal.PingGuList" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="../jquery-easyui-1.3.5/themes/default/easyui.css" rel="stylesheet" />
    <link type="/text/css" href="../jquery-easyui-1.3.5/themes/icon.css" rel="stylesheet" />
    <script src="../easyui/easyui/1.3.2/jquery-1.8.0.min.js"></script>

    <script type="text/javascript" src="../jquery-easyui-1.3.5/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../jquery-easyui-1.3.5/easyloader.js"></script>
    <link href="../jquery-easyui-1.3.5/themes/icon.css" rel="stylesheet" />


    <%--  <link href="../jquery-easyui-1.3.5/themes/default/easyui.css" rel="stylesheet" />
   <link type="/text/css" href="../jquery-easyui-1.3.5/themes/icon.css" rel="stylesheet" />
    <script type="text/javascript" src="../jquery-easyui-1.3.5/jquery-1.7.2-min.js"></script>
    <script type="text/javascript" src="../jquery-easyui-1.3.5/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../jquery-easyui-1.3.5/easyloader.js"></script>
    <script src="../easyui/easyui/1.3.2/locale/easyui-lang-zh_CN.js"></script>--%>

    <script type="text/javascript" src="../easyui/jquery.params.js"></script>
    <%--转换时间格式--%>
    <script src="../Tools/TimeJs.js"></script>

</head>
<body>
    <a href="javascript:void(0) " class="easyui-linkbutton" onclick="pin()">评估</a>
    <iframe width="0" height="0" src="../SessionKeeper.aspx"></iframe>
    <div fit="true">
        <div style="padding: 3px; width: 280px; float: left">
            <select id="sel" class="easyui-combobox" data-options="editable:false">
                <option value="1">所属部门</option>
                <option value="2">勘察人</option>
            </select>
            <select id="dept" class="easyui-combobox" data-options="editable:false">
                <option value="-1">--请选择--</option>
                <%=departmentBD()%>
            </select>
            <input id="namesearsh" class="easyui-validatebox" type="text" name="name"></input>

        </div>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',toggle:true" id="search"  style="float: left">查询</a>
        <table id="dg" title="项目立项列表" style="width: 1190px; height: 600px" data-options="
				singleSelect:true,
				autoRowHeight:false,
				pagination:true,
				pageSize:10">
            <thead>
                <tr>
                    <th field="chek" width="50"></th>
                    <th field="inv" width="140" align="center">项目号</th>
                    <th field="date" width="140" align="center">所属部门</th>
                    <th field="name" width="100" align="center">勘察人</th>
                    <th field="amount" width="160" align="center">勘察开始时间</th>
                    <th field="price" width="160" align="center">勘察结束时间</th>
                    <th field="cost" width="160" align="center">登记日期</th>
                    <th field="note" width="100" align="center">项目状态</th>
                    <th field="cao" width="150" align="center">建议评估单价（元）</th>
                </tr>
            </thead>
        </table>
    </div>

    <script type="text/javascript">
        //跳转评估页
        function pin() {
            var chek = "";
            $(":checkbox:checked").each(function () {
                chek += $(this).val();
            })
            if (chek.length == 0) {
                $.messager.alert("提示", "请选择一个项目进行评估！");
                return;
            }
            if (chek.length != 1) {
                $.messager.alert("", "每次只能评估一个项目！");
            }
            else {
                var xiangId = $(":checkbox:checked").parent().parent().parent().children().eq(1).children().html();
                var Statc = $(":checkbox:checked").parent().parent().parent().children().eq(7).children().text();
                if (Statc == "已勘察/待评估" || Statc == "初审未通过" || Statc == "终审未通过") {
                    parent.addTab("详细信息", "/ProjectAppraisal/PingGuPager.aspx?id=" + xiangId, "icon-chart-organisation", true);
                }
                else {
                    $.messager.alert('温馨提示：', '已评估，不可多次评估');
                }
            }
        }

        //绑定数据表格  deptID, name
        function getData(deptID, name) {
            var rows = [];
            $.ajax({
                type: "post", //要用post方式                 
                url: "PingGuLsit.aspx/showPing",//方法所在页面和方法名
                data: "{'name':'" + name + "','deptID':'" + deptID+"'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                async: false,
                success: function (result) {
                    var json = eval("(" + result.d + ")");

                    for (var i = 0; i < json.length; i++) {
                        rows.push({
                            chek: '<input type="checkbox" value="1"/>',
                            inv: json[i].projectNumber,
                            date: json[i].department_Name,
                            name: json[i].users_Name,
                            amount: (new Date(json[i].survey_StartTime)).Format("yyyy-M-d h:m:s.S"),
                            price: (new Date(json[i].survey_EndTime)).Format("yyyy-M-d h:m:s.S"),
                            cost: (new Date(json[i].basic_CreateTime)).Format("yyyy-M-d h:m:s.S"),
                            note: json[i].basic_State == 0 ? "保存未提交" : json[i].basic_State == 1 ? "已提交/待勘察" : json[i].basic_State == 2 ? "勘察中" : json[i].basic_State == 3 ? "已勘察/待评估" : json[i].basic_State == 4 ? "评估进行中" : json[i].basic_State == 5 ? "已评估/待初审" : json[i].basic_State == 6 ? "初审未通过" : json[i].basic_State == 7 ? "初审通过" : json[i].basic_State == 8 ? "终审未通过" : "终审通过",
                            cao: json[i].basic_UnitPrice,
                        });
                    }
                }
            })
            return rows;
        }

        function pagerFilter(data) {
            if (typeof data.length == 'number' && typeof data.splice == 'function') {	// is array
                data = {
                    total: data.length,
                    rows: data
                }
            }
            var dg = $(this);
            var opts = dg.datagrid('options');
            var pager = dg.datagrid('getPager');
            pager.pagination({
                onSelectPage: function (pageNum, pageSize) {
                    opts.pageNumber = pageNum;
                    opts.pageSize = pageSize;
                    pager.pagination('refresh', {
                        pageNumber: pageNum,
                        pageSize: pageSize
                    });
                    dg.datagrid('loadData', data);
                },
                onRefresh: function (pageNum, pageSize) {
                    $('#dg').datagrid({
                        loadFilter: pagerFilter,
                    }).datagrid('loadData', getData());
                }
            });
            if (!data.originalRows) {
                data.originalRows = (data.rows);
            }
            var start = (opts.pageNumber - 1) * parseInt(opts.pageSize);
            var end = start + parseInt(opts.pageSize);
            data.rows = (data.originalRows.slice(start, end));
            return data;
        }

        function BindData(deptID, name) {
            $('#dg').datagrid({
                loadFilter: pagerFilter,
            }).datagrid('loadData', getData(deptID, name));
        }


        $(function () {
            //搜索
            $("#search").bind('click', function () {
                var deptID = $("#dept").combobox('getValue');//部门编号
                var name = $("#namesearsh").val();//勘察人
                if (deptID == -1) {
                    BindData(deptID, name); 
                }
                else {
                    BindData(deptID,name);
                }
            })
            $("#namesearsh").hide();
            var deptID = -1;
            var name = $("#namesearsh").val();
            BindData(deptID, name ); 
            //开始查询切换下拉框与文本框            
            $("#sel").combobox({
                onChange: function (n, o) {
                    var value = $('#sel').combobox("getValue");
                    if (value != 1) {
                        $("#dept").next().hide();
                        $("#namesearsh").show();
                    }
                    else {
                        $("#namesearsh").hide();
                        $("#dept").next().show();
                    }
                }
            });
            //结束查询切换下拉框与文本框

        });
    </script>
</body>
</html>

